<?php
/**
 * Created by PhpStorm.
 * User: xiaomeng
 * Date: 17-9-18
 * Time: 下午4:20
 */
namespace swf\common;


class ToBet
{
    private $curl = null;
    private $url = "http://127.0.0.1:9500";

    public function __construct()
    {
        $this->curl = new Curl();
    }


    public function bet($noId,$userId = null)
    {
        $url = $this->getUrl('/api/bet/bet');
        $url .= '?noId='.$noId;
        if(!is_null($userId))
        {
            $url .= '&userId='.$userId;
        }
        return $this->curl->get($url);
    }

    public function offlinePrize($noId)
    {
        $url = $this->getUrl('/api/bet/offlinePrize');
        $url .= '?noId='.$noId;
        return $this->curl->get($url);
    }


    public function offlineBetRefund($order_ids)
    {
        $url = $this->getUrl('/api/bet/offlineBetRefund');
        $url .= '?order_ids='.$order_ids;
        return $this->curl->get($url);
    }

    private function getUrl($reqUrl)
    {
        return $this->url.$reqUrl;
    }


    /**
     * 解析数据
     * @param $data
     * @return mixed
     */
    private function decodeData($data)
    {
        return json_decode($data,true);
    }
}
